from util import *

session = Session()
session.connect()

# def registerCallback(name, storedTemplateId):
# 	if helper.session.loadChar(templateId = storedTemplateId):
# 		data = helper.session.uploadChar()
# 		print(data)

# helper.registerFinger(callback = registerCallback)

for i in range(0, 2):
	print("Please put you finger on the scanner.")
	while True:
		if session.detectFinger():
			if session.saveImage():
				if session.generateTemplate(i):
					print("Finger scan completed. Please remove your finger.")
				else:
					print("Register faild!")
					exit()
			else:
				print("Register faild!")
				exit()
			break
		else:
			continue
	while True:
		if session.detectFinger():
			continue
		else:
			break
if not session.mergeTemplate(count = 2):
	print("Register faild!")
	exit()
storeTplId = session.storeChar()
if storeTplId == None: 
	print("Register faild!")
	exit()
print("storeTplId: ", storeTplId)
print("Register completed!")
exit()